package com.xyz.basesdk.utils;

import android.support.annotation.NonNull;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.xyz.basesdk.base.BaseApplication;

/**
 * @author mac
 * on 2018/3/26.
 */

public class ImageUtil {
    public static void loadImage(String imageUrl, ImageView imageView) {
        if (null == imageUrl || null == imageView) return;
        Glide.with(BaseApplication.getContext())
                .load(imageUrl)
                .into(imageView);
    }

    public static void loadImage(int imgId, ImageView imageView) {
        Glide.with(BaseApplication.getContext())
                .load(imgId)
                .into(imageView);
    }

    public static void loadImageWithHint(String imageUrl, ImageView imageView, int hintImgId) {
        if (null == imageUrl || null == imageView) return;
        Glide.with(BaseApplication.getContext())
                .load(imageUrl)
                .into(imageView);
    }

    public static void loadImageWithError(String imageUrl, ImageView imageView, int hintImgId) {
        if (null == imageUrl || null == imageView) return;
        Glide.with(BaseApplication.getContext())
                .load(imageUrl)
                .into(imageView);
    }

    public static void loadImageWithHeadIcon(@NonNull String imageUrl, @NonNull ImageView imageView) {
        Glide.with(BaseApplication.getContext())
                .load(imageUrl)
                .into(imageView);
    }
}
